<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>管理员管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- <h1>菜单管理</h1> -->
    <el-button type="primary" size="small" @click="change">添加</el-button>
    <v-list @edit="edit" ref="listed" @getCount="getCount" @rolads="rolad" ></v-list>
    <v-pagtion :totals="totalnum" @search="search"></v-pagtion>
    <v-dialog :dialist="dialog" @cancle="cancle" ref="dialogs" @rolad="rolad"></v-dialog>
  </div>
</template>

<script>
import vList from "./list";
import vDialog from "./dialog";
import vBread from "../../common/elBread";
import vPagtion from "../../common/elPag";
import {countUser} from '../../util/axios'
export default {
  components: {
    vList,
    vDialog,
    vBread,
    vPagtion
  },
  data() {
    return {
      dialog: {
        isShow: false,
        isAdd: true,
      },
      totalnum:0,
    //   userlist:[]
    };
  },
  methods: {
    //添加功能
    change() {
      this.dialog.isShow = true;
      this.dialog.isAdd = true;
    },
    cancle(e) {
      this.dialog.isShow = e;
    },
    //子组件的编辑功能，由父组件dialog
    edit(e) {
      this.$refs.dialogs.lookup(e);
      this.dialog.isAdd = false;
      this.dialog.isShow = true;
    },
    //分页器上定义的搜索功能
    search(e){
        // console.log(e);
        this.$refs.listed.search(e);
     },
     //点击子组件的添加后,更新数据
     rolad(){
        this.$refs.listed.pageList();
        this.getCount();
        // this.dialog.isShow = false;
     },
     getCount(){
         countUser().then(res=>{
            if(res.code == 200){
               this.totalnum = res.list[0].total;
            }
        })
     }
  },
    mounted(){
      //获得管理员总数 给 pag组件
      this.getCount();
  }
  
};
</script>

<style scoped>
.el-button {
  margin-top: 15px;
}
</style>